package com.tgy.blog.controller;

import com.tgy.ao.LoginAo;
import com.tgy.ao.UserRegisterAo;
import com.tgy.blog.service.DeskUserService;
import com.tgy.result.GraceJSONResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author tianguiyin
 * @version 1.0
 * @date 2022/7/19 10:34
 */
@Validated
@Api(value = "博客文章控制器", tags = {"博客文章"})
@RestController
@RequestMapping("/blog/user")
public class DeskUserController {

    @Resource
    private DeskUserService deskUserService;


    @ApiOperation("登录")
    @PostMapping("login")
    public GraceJSONResult login(LoginAo ao){
        return deskUserService.login(ao);
    }

    @ApiOperation("注册")
    @PostMapping("register")
    public GraceJSONResult register(UserRegisterAo ao){
        return deskUserService.register(ao);
    }

    @ApiOperation("退出")
    @PostMapping("logout")
    public GraceJSONResult login(){
        return deskUserService.logout();
    }

}
